from peewee_async import MySQLDatabase, Manager
from common.config.settings import MySQLConfig


def init_db(loop, db_config: MySQLConfig):
    from common.g.g import DB_PROXY
    db_base = MySQLDatabase(**db_config.dict())
    DB_PROXY.initialize(db_base)
    return Manager(DB_PROXY, loop=loop)


